package bookshop.service.impl;

import java.util.List;

import bookshop.dao.BrowsHistoryDao;
import bookshop.dao.DaoFactory;
import bookshop.domain.Book;
import bookshop.domain.Browsing;
import bookshop.service.BrowsingHistoryService;

public class BrowsingHistoryServiceImpl implements BrowsingHistoryService {

	public void savaBrowsHistory(Browsing brows){
		BrowsHistoryDao browsHistoryDao = (BrowsHistoryDao)DaoFactory.getDao("browsingHistory");
		
		if(browsHistoryDao.getBrowsByConnection(brows.getBook().getBookCode(), brows.getSessionId())==null){
		browsHistoryDao.saveBrowsHistory(brows);
		}
		
	}
	
	public List<Browsing> getBrowssBySessionId(String sessionId){
		BrowsHistoryDao browsHistoryDao = (BrowsHistoryDao)DaoFactory.getDao("browsingHistory");
		
		return browsHistoryDao.getBrowssBySessionId(sessionId);
	}
	
	public List<Book> getBookByBrows(String bookCode,String sessionId){
		BrowsHistoryDao browsHistoryDao = (BrowsHistoryDao)DaoFactory.getDao("browsingHistory");
		return browsHistoryDao.getBookByBrows(bookCode,sessionId);
	}
	
}
